package com.bdqn.tour.servlet.Yml;

import com.bdqn.tour.dao.CityDao;
import com.bdqn.tour.dao.impl.CityServletDaoimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/ymlUpdateUserInfo")
public class YmlUpdate extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置编码
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        //接收参数
        String id = req.getParameter("id");
        String Addressname = req.getParameter("Addressname");
        String price = req.getParameter("price");
        String score = req.getParameter("score");
        String brand = req.getParameter("brand");
        String evaluation = req.getParameter("evaluation");
        //调用方法
        CityDao cityDao = new CityServletDaoimpl();
        //调用方法上传参数
        int row = cityDao.upadtecity(id, Addressname, price, score, brand, evaluation);
        if (row > 0) {
            resp.getWriter().print("success");
        } else {
            resp.getWriter().print("error");
        }
        resp.getWriter().close();
    }
    }

